%the revisible part are K,N,RNK, R(s), sigma(s), y0, tspan
clear all
% parametor of index J
K=40;
%JNKR = index(K,N,RNK);
alphas = [zeros(1,K);eye(K)];
fname='alphas';
save(fname,'alphas');
load(fname,'betas');
% time 
t = 1/2;
% construct orthogoal basis in L2[0,t]
orthbasis(t);
% initial condition
X0=zeros(size(betas,1),1);
X0(1)=1;
% solver
num=50;
tspan = linspace(0,t,num+1);
options = odeset('AbsTol',1e-12,'RelTol',1e-6);
%for mean
%%Y=zeros(51,1);
%for var
%sig=zeros(num+1,size(betas,1));
%ms' value
msvalue(num)


tic

[time,X] = ode45(@randomasset,tspan,X0,[]);
%[time,y]=ode15s(@randomou,tspan,y0,[],para);
%Y=Y+y(:,1); %for mean
%Y=Y+y.*y; %for var
toc

% error
%meanerr(time',y,R,sig,y0,Y/numpath)
varerr(time',X,a,m,b,X0(1),X.*X)


